PART - A

1. Import and Understand the data [7 Marks]

A. Import and read ‘images.npy’. [1 Marks]

Loaded the images to images_arr. It has 409 images with image details.

B. Split the data into Features(X) & labels(Y). Unify shape of all the images. [3 Marks]

Imp Note: Replace all the pixels within masked area with 1. Hint: X will comprise of array of image whereas Y will comprise of coordinates of the mask(human face). Observe: data[0], data[0][0], data[0][1].

To understand the input images array and its content, let us take a sample
From the above prints, images_arr contains images and its corresponding labels. images_arr[0][0] is an image and images_arr[0][1] holds label details. To understand more let us plot some images.
For every image in images, labels hold a list of dictionaries holding information on the faces identified. I.e if an image contains 1 face, the corresponding labels list have only one dict. If the image has 5 faces, then the corresponding labels have a list of 5 dicts. Let us see through samples.

Image 207 has only one person and hence its corresponding labels hold a list of 1 dict.

image 4 contains 6 faces, hence corresponding labels is a list of 6 dicts with details of 6 faces (coordinates, width, height, etc)

The area where the face is present in the image is identified correctly and masked with Yellow.

C. Split the data into train and test[400:9]. [1 Marks]

D. Select random image from the train data and display original image and masked image. [2 Marks]

All the faces in the above image are correctly identified and masked with yellow.

2. Model building [11 Marks]

A. Design a face mask detection model. [4 Marks]

Hint: 1. Use MobileNet architecture for initial pre-trained non-trainable layers. Hint: 2. Add appropriate Upsampling layers to imitate U-net architecture.

B. Design your own Dice Coefficient and Loss function. [2 Marks]

C. Train and tune the model as required. [3 Marks]

D. Evaluate and share insights on performance of the model. [2 Marks]

Insights:

3. Test the model predictions on the test image: ‘image with index 3 in the test data’ and visualise the predicted masks on the faces in the image. [2 Marks]

Insights: As shown in the baove images, the model has correctly masked the face on the actual image.

PART B

1. Read/import images from folder ‘training_images’. [2 Marks]

2. Write a loop which will iterate through all the images in the ‘training_images’ folder and detect the faces present on all the images. [3 Marks]

Hint: You can use ’haarcascade_frontalface_default.xml’ from internet to detect faces which is available open source

3. From the same loop above, extract metadata of the faces and write into a DataFrame. [3 Marks]

4. Save the output Dataframe in .csv format. [2 Marks]

PART C

1. Unzip, read and Load data(‘PINS.zip’) into session. [2 Marks]

2. Write function to create metadata of the image. [4 Marks]

Hint: Metadata means derived information from the available data which can be useful for particular problem statement.

3. Write a loop to iterate through each and every image and create metadata for all the images. [4 Marks]

4. Generate Embeddings vectors on the each face in the dataset. [4 Marks]

Hint: Use ‘vgg_face_weights.h5’

5. Build distance metrics for identifying the distance between two similar and dissimilar images. [4 Marks]

As shown above, the pair of images belong to same person and distance calculated is closer to 0
As shown above, the pair of images belong to different person and distance calculated is closer to 1

6. Use PCA for dimensionality reduction. [2 Marks]

7. Build an SVM classifier in order to map each image to its right person. [4 Marks]

As we can see above the test classes and predicted classes are same for the samples.

8. Import and display the the test images. [2 Marks]

Hint: ‘Benedict Cumberbatch9.jpg’ and ‘Dwayne Johnson4.jpg’ are the test images.

9. Use the trained SVM model to predict the face on both test images. [4 Marks

The model has correctly predicted the names of the actors present in the 2 given images

THE END